package view;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import modell.Knapp;
import modell.Minutt;
import modell.Sekund;
import modell.Time;
import modell.Urverk;
import modell.Viser;

public class Klokke extends JFrame {

	private static final long serialVersionUID = -4464358460865902060L;

	private Knapp opp, ned;
	private Viser sekund, minutt, time;
	private Display display;
	private ValgPanel panel;
	private Urverk ur;
	private StoppeKnapp startStopp;
	private JPanel viserPanel;
	
	public Klokke(){
		super("Klokkeprogram");
		
		time = new Time(23, 00);
		minutt = new Minutt(time,59, 00);
		sekund = new Sekund(minutt,59, 00);
		viserPanel = new JPanel();
		
		display = new Display();
		time.leggTilLytter(display);
		viserPanel.add(display);
		
		display = new Display();
		minutt.leggTilLytter(display);
		viserPanel.add(display);
		
		display = new Display();
		sekund.leggTilLytter(display);
		viserPanel.add(display);
		
		ur = new Urverk(sekund);
		
		startStopp = new StoppeKnapp(ur);
		opp = new KnappOpp(sekund);
		ned = new KnappNed(sekund);
		
		panel = new ValgPanel(opp, ned, time,minutt,sekund);

		setLayout(new BorderLayout());
		add(panel, BorderLayout.NORTH);
		add(opp, BorderLayout.EAST);
		add(ned, BorderLayout.WEST);
		add(viserPanel, BorderLayout.CENTER);
		add(startStopp, BorderLayout.SOUTH);
		
		setSize(210, 120);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
		ur.start();
	}
	
	public static void main(String[] args) {
		new Klokke();
	}

}
